//
//  GYMakeOrderVC.m
//  GYDemo
//
//  Created by Mrzhang on 2018/4/11.
//  Copyright © 2018年 mac. All rights reserved.
//

//
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                  \\`.
//        .'//                     |                     \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
//    .'//.-"                 `-.  |  .-'                 "-.\\`.
//  .'//______.============-..   \ | /   ..-============.______\\`.
//.'______________________________\|/______________________________`.
//
//

#import "GYMakeOrderVC.h"
#import "Head.h"
#import "GYMakeOrderCell.h"
#import "GYMineShopAddressVC.h"
@interface GYMakeOrderVC ()
@property(nonatomic,strong)UILabel *totallb;
@property(nonatomic,strong)UILabel *transLab;
@property(nonatomic,strong)NSMutableDictionary *dataSource;
@property(nonatomic,strong)UIView *btomView;

@end

@implementation GYMakeOrderVC
#pragma mark - getter and setter
-(NSMutableDictionary *)goodData
{
    if (!_goodData) {
        _goodData=[[NSMutableDictionary alloc] init];
    }
    return _goodData;
}
-(int)getRandomNumber:(int)from to:(int)to
{
    return (int)(from + (arc4random() % (to - from + 1)));
}
-(UIView *)btomView
{
    if (!_btomView) {
        _btomView=[[UIView alloc] init];
        _btomView.y=self.view.height-WFCGFloatY(45)-GY_Nav_height;
        _btomView.x=0;
        _btomView.width=self.view.width;
        _btomView.height=WFCGFloatY(45);
        _btomView.backgroundColor=[UIColor whiteColor];
        [WFFunctions WFUIaddBorderToView:_btomView top:1 left:0 bottom:0 right:0 borderColor:Main_Color_BG borderWidth:1];
        
        UIButton* btn=[UIButton buttonWithType:UIButtonTypeCustom];
        [btn setTitle:@"提交订单" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn.backgroundColor=Main_Color_Red;
        btn.titleLabel.font=SYSTEMFONT(15);
        btn.width=WFCGFloatX(105);
        btn.height=WFCGFloatY(45);
        btn.y=0;
        btn.x=self.view.width-WFCGFloatX(105);
        @WeakSelf;
        [btn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
            if ([GYMineShopAddressViewModel shareInterface].defaultAddress)
            {

                
                NSMutableDictionary* para=[NSMutableDictionary new];
                [para setObject:_model.imgpath forKey:@"imgpath"];
                [para setObject:_model.name forKey:@"goodname"];
                [para setObject:[NSString stringWithFormat:@"%@",_model.price] forKey:@"price"];
                [para setObject:@"1" forKey:@"num"];
                [para setObject:[NSString stringWithFormat:@"%@%@",[GYMineShopAddressViewModel shareInterface].defaultAddress.province,[GYMineShopAddressViewModel shareInterface].defaultAddress.address] forKey:@"address"];
                [para setObject:[GYMineShopAddressViewModel shareInterface].defaultAddress.name forKey:@"linkname"];
                [para setObject:[GYMineShopAddressViewModel shareInterface].defaultAddress.phone forKey:@"phone"];
                [para setObject:@"0" forKey:@"status"];
                [para setObject:[NSString stringWithFormat:@"20192030%d",[self getRandomNumber:100000 to:999999]] forKey:@"ordernum"];
                [self requestAdd:para];
            }else
            {
                [FTIndicator showErrorWithMessage:@"请填写收货地址"];
            }
            
        }];
        [_btomView addSubview:btn];
    }
    return _btomView;
}
-(NSMutableDictionary *)dataSource
{
    if (!_dataSource) {
        _dataSource=[[NSMutableDictionary alloc] init];
    }
    return _dataSource;
}

-(UILabel *)totallb
{
    if (!_totallb)
    {
       _totallb = [UILabel new];
        _totallb.x = 0;
        _totallb.width = WFCGFloatX(260);
        _totallb.y =WFCGFloatY(6);
        _totallb.height = WFCGFloatY(25);
        _totallb.font = SYSTEMFONT(14);
        _totallb.textColor = Main_Color_Black;
        _totallb.textAlignment = NSTextAlignmentRight;
       
    }
    return _totallb;
}
-(UILabel *)transLab
{
    if (!_transLab)
    {
        _transLab = [UILabel new];
        _transLab.x = 0;
        _transLab.width = WFCGFloatX(260);
        _transLab.y = WFCGFloatY(29);
        _transLab.height = WFCGFloatY(14);
        _transLab.font = SYSTEMFONT(10);
        _transLab.textColor = HEXCOLOR(@"#666666");
        _transLab.textAlignment = NSTextAlignmentRight;
        
    }
    return _transLab;
}

-(void)initilization
{
    self.navigationItem.title = @"采购订单确认";
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    self.view.backgroundColor = Main_Color_Red;
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    [self.view addSubview:self.baseTable];
    [self.view addSubview:self.btomView];
    [self.btomView addSubview:self.totallb];
    [self.btomView addSubview:self.transLab];
    [self.baseTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.baseTable setSeparatorColor: Main_Color_BG];
    [self.baseTable setBackgroundColor:Main_Color_BG];
    [self.baseTable setTintColor:Main_Color_BG];
    if (@available(iOS 11.0, *)) {
        // self.baseTable.contentInset = UIEdgeInsetsMake(-GY_Nav_height, 0, 0, 0);
    }
    self.baseTable.mj_header.backgroundColor = Main_Color_Red;
    self.baseTable.scrollIndicatorInsets = self.baseTable.contentInset;

}
-(void)inputComment
{
    NSString *title = @"给买家留言";
    NSString *hold1 = @"请输入留言";
    TYAlertView *alertView = [TYAlertView alertViewWithTitle:title message:nil];
    [alertView addAction:[TYAlertAction actionWithTitle:@"取消" style:TYAlertActionStyleCancel handler:^(TYAlertAction *action) {
        NSLog(@"%@",action.title);
    }]];
    @WeakSelf;
    [alertView addAction:[TYAlertAction actionWithTitle:@"确定" style:TYAlertActionStyleDestructive handler:^(TYAlertAction *action) {
        UITextField *mintf = alertView.textFieldArray[0];
        if (mintf.text.length > 0) {
            NSString *min = mintf.text;
           // model.comment = min;
            [_dataSource setObject:min forKey:@"remark"];
            [selfp.baseTable reloadData];
        }else{
            [FTToastIndicator showToastMessage:@"请填写完整"];
        }
    }]];
    
    [alertView addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        textField.placeholder = hold1;
        textField.keyboardType = UIKeyboardTypeDefault;
        [textField becomeFirstResponder];
        textField.text = [_dataSource objectForKey:@"remark"];
    }];
    alertView.clickedAutoHide = YES;
    TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:alertView preferredStyle:TYAlertControllerStyleAlert];
    
    //alertController.alertViewOriginY = 60;
    [self presentViewController:alertController animated:YES completion:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.isGroup=YES;

    [self initilization];
    
    [[InterfaceManager shareInterface].specialInterfaces addObject:@"buyMakeOrder"];

    self.dataSource[@"num"]=_countNum;
    //self.dataSource[@"proid"]=[NSString stringWithFormat:@"%@",_model.id];

    
  //  [self requestOrder];
    [self viewModelBand];
    [self setHeaderData];

}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
   // [self.baseTable reloadData];
}
-(void)viewModelBand
{
    @WeakSelf;
    
    GCBaseObservationModel *loginOb = [GCBaseObservationModel new];
    loginOb.observation = [GYMineShopAddressViewModel shareInterface];
    loginOb.keyPath = @"defaultAddress";
    loginOb.handler = ^(NSString *keyPath) {
        [selfp.baseTable reloadData];
    };
    [self registObservation:loginOb];

}
#pragma mark - delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row==1) {
        
        CGSize temSize=[WFFunctions WFStrGetSize:[_dataSource objectForKey:_model.name] width:WFCGFloatX(200) font:SYSTEMFONT(13)];
        if (temSize.height<WFCGFloatY(50)) {
            return WFCGFloatY(50);
        }
        
        return temSize.height+10;;
    }
    if (indexPath.row==2) {
        return WFCGFloatY(80);
    }
    return WFCGFloatY(90);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    
    UIView *view = [UIView new];
    view.width = self.view.width;
    view.height = WFCGFloatY(39.5) + 5;
    view.backgroundColor = Main_Color_White;
    
    UILabel *titlelb = [UILabel new];
    titlelb.y = 5;
    titlelb.x = WFCGFloatX(19);
    titlelb.width = WFCGFloatX(230);
    titlelb.height = WFCGFloatY(39.5);
    titlelb.font = SYSTEMFONT(15);
    titlelb.textColor = Main_Color_Black;
    [view addSubview:titlelb];
    if (_goodData.count!=0) {
        titlelb.text =[[[_goodData objectForKey:@"datalist"] objectAtIndex:0] objectForKey:@"companyname"];
    }
    
    
    UIButton *phonenumbtn = [UIButton new];
    phonenumbtn.x = WFCGFloatX(375-113);
    phonenumbtn.width = WFCGFloatX(100);
    phonenumbtn.height = WFCGFloatX(16.5);
    phonenumbtn.centerY = view.centerY;
    phonenumbtn.titleLabel.font = SYSTEMFONT(12);
    [phonenumbtn setTitle:_infoModel.loginmobile forState:UIControlStateNormal];
    [phonenumbtn setTitleColor:Main_Color_Gray forState:UIControlStateNormal];
    [phonenumbtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
        [[GCPresenter shareInterface]phoneCall:_infoModel.loginmobile];
    }];
    [phonenumbtn setEnlargeEdge:10];
    [view addSubview:phonenumbtn];

    return view;

}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return WFCGFloatY(45);
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.row==1)
    {
        static NSString *CellID = @"CellID1";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellID];
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            cell.backgroundColor=[UIColor whiteColor];
        }
        [cell.contentView removeAllSubviews];
        
        cell.textLabel.font=SYSTEMFONT(14);
        cell.textLabel.textColor=HEXCOLOR(@"#333333");
        cell.textLabel.text=@"给卖家留言:";
        
        
        cell.detailTextLabel.text=[_dataSource objectForKey:@"remark"]?:@"填写留言内容";
        cell.detailTextLabel.font=SYSTEMFONT(13);
        cell.detailTextLabel.textColor=HEXCOLOR(@"#999999");
        cell.detailTextLabel.numberOfLines=0;
        
        UIImageView* line=[[UIImageView alloc] init];
        line.x=0;
        line.y=cell.height-1;
        line.width=ScreenWidth;
        line.height=.5;
        line.backgroundColor=HEXCOLOR(@"#F1F1F2");
        [cell.contentView addSubview:line];
        
        return cell;
    }
    if (indexPath.row==2)
    {
        static NSString *CellID = @"CellID2";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            cell.backgroundColor=[UIColor whiteColor];
        }
        [cell.contentView removeAllSubviews];
        
        UIImageView* locationIV=[[UIImageView alloc] init];
        locationIV.image=[UIImage imageNamed:@"dizhi"];
        locationIV.x=0;
        locationIV.y=0;
        locationIV.width=locationIV.image.size.width;
        locationIV.height=WFCGFloatY(80);
        [cell.contentView addSubview:locationIV];
        cell.textLabel.font=SYSTEMFONT(14);
        cell.textLabel.textColor=HEXCOLOR(@"#333333");
        cell.textLabel.numberOfLines=2;
        
        if ([GYMineShopAddressViewModel shareInterface].defaultAddress)
        {
            NSString *province = [GYMineShopAddressViewModel shareInterface].defaultAddress.province;
            NSString *address = [GYMineShopAddressViewModel shareInterface].defaultAddress.address;
            NSString *addresses = [NSString stringWithFormat:@"%@%@",province,address];
            
            
            UILabel* titleLab=[[UILabel alloc] init];
            titleLab.x=WFCGFloatX(19);
            titleLab.y=WFCGFloatY(1);
            titleLab.width=WFCGFloatX(300);
            titleLab.height=WFCGFloatY(25);
            titleLab.font=SYSTEMFONT(14);
            titleLab.textColor=Main_Color_Black;
            [cell.contentView addSubview:titleLab];
            titleLab.text=[NSString stringWithFormat:@"收货人:%@   %@",[GYMineShopAddressViewModel shareInterface].defaultAddress.name,[GYMineShopAddressViewModel shareInterface].defaultAddress.phone];
            
            
            UILabel* addressLab=[[UILabel alloc] init];
            addressLab.x=WFCGFloatX(19);
            addressLab.y=WFCGFloatY(25);
            addressLab.width=WFCGFloatX(330);
            addressLab.height=WFCGFloatY(54);
            addressLab.font=SYSTEMFONT(14);
            addressLab.textColor=Main_Color_Black;
            [cell.contentView addSubview:addressLab];
            addressLab.numberOfLines=2;
            addressLab.text=[NSString stringWithFormat:@"收货地址:%@",addresses];
            
            cell.accessoryType=UITableViewCellAccessoryNone;
            cell.textLabel.text=@"";
            
        }else
        {
            cell.textLabel.text=@"添加收货地址";
            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

        }
        
        return cell;
    }
    
    static NSString *CellID = @"CellID";
    GYMakeOrderCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    if (cell == nil) {
        cell = [[GYMakeOrderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.backgroundColor=[UIColor whiteColor];
    }
    [cell setData:_goodData];
    cell.countTF.text=_countNum;
    
    
    cell.nameLB.text =_model.name;
    
    CGSize nameSize=[WFFunctions WFStrGetSize:cell.nameLB.text width:WFCGFloatX(230) font:SYSTEMFONT(13)];
    cell.nameLB.height=nameSize.height;
    
    
    [cell.imageIV sd_setImageWithURL:[NSURL URLWithString:_model.imgpath] placeholderImage:[UIImage imageNamed:@"default_goods"]];
    

    
    NSString *unit = @"1件";
    CGSize unitSize=[WFFunctions WFStrGetSize:unit width:100 font:SYSTEMFONT(12)];
    cell.countLB.text = @"1件";
    NSString *priceUnit = [NSString stringWithFormat:@"¥%@元/%@",_model.price,@"件"];
    cell.priceLB.text = priceUnit;
    
    CGSize CountSize=[WFFunctions WFStrGetSize:_countNum width:100 font:SYSTEMFONT(12)];
    
    
    cell.countTF.x=WF_UI_VIEW_WIDTH - WFCGFloatX(40)-unitSize.width-CountSize.width;
    cell.countTF.y=WFCGFloatY(45+20);
    cell.countTF.width=WFCGFloatX(26)+unitSize.width+CountSize.width;
    cell.countTF.height=WFCGFloatY(25);
    
    
    cell.countLB.x = cell.countTF.width-unitSize.width-5;
    cell.countLB.y = 0;
    cell.countLB.width = unitSize.width;
    cell.countLB.height = WFCGFloatY(25);
    
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==1) {
        [self inputComment];
    }
    if (indexPath.row==2)
    {
        GYMineShopAddressVC* vc=[[GYMineShopAddressVC alloc] init];
        vc.ischoose=YES;
        vc.handler = ^(GYMineShopAddressModel *model) {
            [self.baseTable reloadData];
        };
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [UIView new];
    view.width = self.view.width;
    view.height = WFCGFloatY(48);
    view.backgroundColor = Main_Color_White;
    
    UILabel* titleLab=[[UILabel alloc] init];
    titleLab.x=ScreenWidth-WFCGFloatX(14)-WFCGFloatX(200);
    titleLab.y=WFCGFloatY(0);
    titleLab.width=WFCGFloatX(200);
    titleLab.height=WFCGFloatY(48);
    titleLab.font=SYSTEMFONT(15);
    titleLab.textColor=Main_Color_Black;
    titleLab.textAlignment=NSTextAlignmentRight;
    [view addSubview:titleLab];
    if (_goodData.count!=0)
    {
        NSString* priSt=[NSString stringWithFormat:@"¥%@",[_goodData objectForKey:@"countamount"]];
        NSString* amrkStr=@"小计:";
        NSString* allStr=[NSString stringWithFormat:@"%@%@",amrkStr,priSt];
        
        NSMutableAttributedString *mastr = [[NSMutableAttributedString alloc]initWithString:allStr];
        [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(12) range:[allStr rangeOfString:amrkStr]];
        [mastr addAttribute:NSForegroundColorAttributeName value:Main_Color_Black range:[allStr rangeOfString:amrkStr]];
        
        [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(18) range:[allStr rangeOfString:priSt]];
        [mastr addAttribute:NSForegroundColorAttributeName value:HEXCOLOR(@"#FC1B36") range:[allStr rangeOfString:priSt]];
        titleLab.attributedText = mastr;
    }

    UIImageView* line=[[UIImageView alloc] init];
    line.x=0;
    line.y=0;
    line.width=ScreenWidth;
    line.height=.5;
    line.backgroundColor=HEXCOLOR(@"#F1F1F2");
    [view addSubview:line];
    
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    
    return WFCGFloatY(48);
}
-(void)requestAdd:(NSMutableDictionary*)para
{
    @WeakSelf;
    NSString *interface = @"addUVTOrder";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [FTIndicator showSuccessWithMessage:@"订单已提交"];
        [selfp.navigationController popViewControllerAnimated:YES];
    }];
}

-(void)requestOrder
{
     @WeakSelf;
    NSString *interface = @"buyMakeOrder";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:self.dataSource handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {

        NSDictionary *data = infoModel.data;
        if ([data isKindOfClass:[NSDictionary class]]) {
            _goodData=[[NSMutableDictionary alloc] initWithDictionary:data];
            
            [self setHeaderData];
            
            [selfp.baseTable reloadData];
        }else
        {
            [FTIndicator showErrorWithMessage:[info objectForKey:@"message"]];
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
}
-(void)setHeaderData
{
    self.transLab.text=[NSString stringWithFormat:@"服务费:¥%@",@"0"];
    
    
    NSString* priSt=[NSString stringWithFormat:@"¥%@",_model.price];
    NSString* amrkStr=@"合计:";
    NSString* allStr=[NSString stringWithFormat:@"%@%@",amrkStr,priSt];
    
    NSMutableAttributedString *mastr = [[NSMutableAttributedString alloc]initWithString:allStr];
    [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(12) range:[allStr rangeOfString:amrkStr]];
    [mastr addAttribute:NSForegroundColorAttributeName value:Main_Color_Black range:[allStr rangeOfString:amrkStr]];
    
    [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(18) range:[allStr rangeOfString:priSt]];
    [mastr addAttribute:NSForegroundColorAttributeName value:HEXCOLOR(@"#FC1B36") range:[allStr rangeOfString:priSt]];
    self.totallb.attributedText = mastr;
}
@end


/*
 11111111111111111111111111111111111111001111111111111111111111111
 11111111111111111111111111111111111100011111111111111111111111111
 11111111111111111111111111111111100001111111111111111111111111111
 11111111111111111111111111111110000111111111111111111111111111111
 11111111111111111111111111111000000111111111111111111111111111111
 11111111111111111111111111100000011110001100000000000000011111111
 11111111111111111100000000000000000000000000000000011111111111111
 11111111111111110111000000000000000000000000000011111111111111111
 11111111111111111111111000000000000000000000000000000000111111111
 11111111111111111110000000000000000000000000000000111111111111111
 11111111111111111100011100000000000000000000000000000111111111111
 11111111111111100000110000000000011000000000000000000011111111111
 11111111111111000000000000000100111100000000000001100000111111111
 11111111110000000000000000001110111110000000000000111000011111111
 11111111000000000000000000011111111100000000000000011110001111111
 11111110000000011111111111111111111100000000000000001111100111111
 11111111000001111111111111111111110000000000000000001111111111111
 11111111110111111111111111111100000000000000000000000111111111111
 11111111111111110000000000000000000000000000000000000111111111111
 11111111111111111100000000000000000000000000001100000111111111111
 11111111111111000000000000000000000000000000111100000111111111111
 11111111111000000000000000000000000000000001111110000111111111111
 11111111100000000000000000000000000000001111111110000111111111111
 11111110000000000000000000000000000000111111111110000111111111111
 11111100000000000000000001110000001111111111111110001111111111111
 11111000000000000000011111111111111111111111111110011111111111111
 11110000000000000001111111111111111100111111111111111111111111111
 11100000000000000011111111111111111111100001111111111111111111111
 11100000000001000111111111111111111111111000001111111111111111111
 11000000000001100111111111111111111111111110000000111111111111111
 11000000000000111011111111111100011111000011100000001111111111111
 11000000000000011111111111111111000111110000000000000011111111111
 11000000000000000011111111111111000000000000000000000000111111111
 11001000000000000000001111111110000000000000000000000000001111111
 11100110000000000001111111110000000000000000111000000000000111111
 11110110000000000000000000000000000000000111111111110000000011111
 11111110000000000000000000000000000000001111111111111100000001111
 11111110000010000000000000000001100000000111011111111110000001111
 11111111000111110000000000000111110000000000111111111110110000111
 11111110001111111100010000000001111100000111111111111111110000111
 11111110001111111111111110000000111111100000000111111111111000111
 11111111001111111111111111111000000111111111111111111111111100011
 11111111101111111111111111111110000111111111111111111111111001111
 11111111111111111111111111111110001111111111111111111111100111111
 11111111111111111111111111111111001111111111111111111111001111111
 11111111111111111111111111111111100111111111111111111111111111111
 11111111111111111111111111111111110111111111111111111111111111111
 
 
 */
